package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.BaseBattleStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name="飞雷御执")
@Order(503)
@Component
public class FeiLeiYuZhi extends BaseBattleStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        double v = 2.6;
        BuffContent buff = second.getBuff().get("雷雾");
        if (buff == null) {
            BuffContent buffContent = new BuffContent();
            buffContent.setDuration(10);
            buffContent.setNum(1);
            buffContent.setPositive(false);
            second.getBuff().put("雷雾", buffContent);
        }else {
            v += buff.getNum() * 0.3;
            buff.setDuration(10);
            buff.setNum(1);
        }
        int atk = (int) (first.getBattleInfo().getSpell() * v);
        int def = second.getBattleInfo().getRes();
        int dmg = battleHelper.calSpell(atk, def);
        battleHelper.autoAction(this, first, second, content, dmg, "飞雷御执");
        first.getCd().put("飞雷御执", 4);
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("该战技无法直接学习，需要拥有 武器-[飞雷之弦振] ，装备在身上时自动学会");

    }

    @Override
    public String limitDesc() {
        return "学习/使用飞雷御执需要拥有 武器-[飞雷之弦振] ";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        Integer cd = user.getCd().get("飞雷御执");
        if (cd != null && cd > 0) {
            return false;
        }
        return true;
    }

    @Override
    public String desc() {
        return "烟花易逝，人情长存。曾由将军御赐的长弓，闪烁着永不熄灭的雷光。\n造成2.6倍法术伤害，并为对方附加[雷雾]buff，并在下次释放飞雷御执时引爆所有雷雾，每层雷雾增加0.3的倍率，cd4\n雷雾：每次受到攻击会增加一层计数，最高3层。当雷雾3层时，每回合扣除15%mp";
    }

}
